package ThreadPool.chapter3;

import java.util.concurrent.TimeUnit;

public class NoVisibility2 {

    private static volatile boolean flag;

    private static int number;

    public static class readThread extends Thread {
        @Override
        public void run() {
            while(!flag){

            }
            System.out.println(number);
        }
    }


    public static void main(String[] args) throws InterruptedException {
        new readThread().start();
        TimeUnit.MILLISECONDS.sleep(20);
        number = 42;
        flag = true;
    }

}
